home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / asm32v20.zip / SYSTEM.DOC < prev    next >
Text File  |  1995-01-09  |  17KB  |  613 lines

  1.  
  2. *****************************  SYSTEM  *************************************
  3.  
  4. ASM32 system subroutines Copyright (C) 1993 - 1995 Douglas Herr
  5. all rights reserved
  6.  
  7.  
  8. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  9.  
  10. COLOR16:     calculate color value for palette register
  11. Source:      color16.asm
  12.  
  13. Call with:   EBX pointing to red value (0-3), green value (0-3)
  14.              and blue value (0-3); see also Palette16
  15. Returns:     AH = color value for 16-color palette register
  16. Uses:        AH
  17. Supports:    VGA 16-color modes (text or graphics)
  18.              EGA 16-color modes, except with CGA monitor
  19. Example:
  20.  
  21. extrn   color16:near
  22.  
  23. include dataseg.inc
  24.  
  25. c16     db 3                  ; brightest red
  26.         db 1                  ; dim green
  27.         db 0                  ; no blue
  28.  
  29. @curseg ends
  30.  
  31. include codeseg.inc
  32.         .
  33.         .
  34.         .
  35.         lea   ebx,c16
  36.         call  color16
  37.  
  38.  
  39.  
  40. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  41.  
  42. EXENAME:     determine the full path and filename of the executing program
  43. Source:      exename.asm (strlen.asm)
  44.  
  45. Call with:   no parameters
  46. Returns:     ES:[EBX] pointing to the the name of the executing program,
  47.              including drive and full path.
  48.              The filename returned is an ASCIIZ string in the program's
  49.              environment segment, and may be mixed upper- and lower-case
  50.              characters.  You may use STRNDUP to copy the far pointer to
  51.              near data.
  52.  
  53.              Version 2.0: Note that EXENAME does not copy the path string to
  54.              near data.  It returns a far address to the program name which
  55.              you may copy to near data with STRNDUP if you wish.
  56.  
  57. Uses:        ES, EBX, ECX, flags
  58. Example:
  59.  
  60. extrn   exename:near
  61.  
  62. include codeseg.inc
  63.  
  64.         .
  65.         .
  66.         .
  67.         call  exename         ; string returned at [EBX] in low heap
  68.  
  69.  
  70.  
  71. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  72.  
  73. EXESIZE:     determine size of .EXE program
  74. Source:      exesize.asm
  75.  
  76. Call with:   [EDX] pointing to ASCIIZ .EXE filename
  77. Returns:     if CF = 1, AX = DOS error code
  78.                         if AX = 0, not an EXE-format file
  79.              if CF = 0, EAX = bytes in .EXE file loaded by DOS program
  80.                         loader and by CauseWay
  81.              Note that additional data may be copied to the end of a DOS
  82.              .EXE file with the DOS COPY /B command.  This is handy for
  83.              help screens or other such data that you want to keep with
  84.              the .EXE file, but that you don't want to be loaded in memory
  85.              with the program.  If you do copy additional data to the .EXE
  86.              file, EXESize will report only the portion of the file loaded
  87.              in RAM by the DOS program loader and CauseWay, while FSize (in
  88.              DISK.DOC) reports the entire file size.
  89. Uses:        EAX, flags
  90. Example:
  91.  
  92. ;
  93. ; code used to test EXEsize
  94. ;
  95. include model.inc
  96.  
  97. public  testcode
  98. extrn   exename:near, exesize:near
  99. extrn   strndup:near, i4tostr:near
  100. extrn   tprint:near, getkey:near
  101.  
  102. include dataseg.inc
  103. extrn   pspseg:word
  104. space   db 20 dup(0)
  105. @curseg ends
  106.  
  107. include codeseg.inc
  108. testcode        proc near
  109.         mov     es,pspseg
  110.         call    exename         ; get name of this program
  111.         call    strndup         ; copy to near heap
  112.                                 ; startup code was assembled with /DHEAP
  113.         mov     edx,ebx         ; [EDX] -> EXE filename
  114.         call    exesize         ; EAX = EXE program size
  115.         lea     esi,space
  116.         call    i4tostr         ; convert to ASCIIZ string
  117.         xor     edx,edx         ; point to UL corner of screen
  118.         mov     ah,12           ; "can't miss it" color
  119.         call    tprint          ; print it
  120.         call    getkey          ; don't scroll off screen yet
  121.         ret                     ; go back to calling code
  122. testcode        endp
  123.  
  124. @curseg ends
  125.         end
  126.  
  127.  
  128. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  129.  
  130. FLOPPIES:    determine the number of floppy disk drives intalled
  131. Source:      floppies.asm
  132.  
  133. Call with:   no parameters
  134. Returns:     AX = number of floppy drives
  135. Uses:        AX; all other registers and flags are saved
  136. Example:
  137.  
  138. include model.inc
  139.  
  140. extrn   floppies:near
  141.  
  142. include codeseg.inc
  143.  
  144. myproc  proc   near
  145.         .
  146.         call   floppies
  147.  
  148.  
  149.  
  150. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  151.  
  152. FLOPPYTYPE:  determine the type of floppy disk drives intalled
  153. Source:      floptype.asm
  154.  
  155. Call with:   DL = drive number (0 = drive A:)
  156. Returns:     AX = floppy drive type
  157.               0 = invalid drive number
  158.               1 = 360k
  159.               2 = 1.2M
  160.               3 = 720k
  161.               4 = 1.44M
  162. Uses:        AX, flags
  163. Example:
  164.  
  165. include model.inc
  166.  
  167. public  myproc
  168. extrn   floppytype:near
  169.  
  170. .data
  171. drive_number   db 0
  172.  
  173. .code
  174. myproc  proc
  175.         .
  176.         mov    dl,drive_number
  177.         call   floppytype
  178.         or     ax,ax
  179.         jz     bad_drive_number
  180.  
  181. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  182.  
  183. GETCPU:      detects cpu type
  184. Source:      getcpu.asm
  185.  
  186. Call with:   no parameters
  187. Returns:     AX = 3 if 386 (SX or DX)
  188.              AX = 4 if 486 (SX or DX)
  189. Uses:        AX
  190. Example:     call   getcpu
  191.  
  192.  
  193.  
  194. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  195.  
  196. GETCRT:      determines active monitor type
  197. Source:      getcrt.asm ($herc.asm, isevga.asm)
  198.  
  199. Call with:   no parameters
  200. Returns:     AX = code for active video system
  201.              CGA = -1
  202.              MDA = 0
  203.              EGA mono = 0100h
  204.              VGA mono = 0300h
  205.              EGA color = 1
  206.              MCGA = 2
  207.              VGA color = 3
  208.              HGC = 128
  209.              HGC+ = 144
  210.              InColor = 208
  211.              Note: GetCRT may be re-assembled with the /DNOHERC switch
  212.              to eliminate code which detects Hercules equipment
  213. Uses:        AX
  214. Supports:    CGA, MCGA, MDA, HGC, HGC+, InColor, EGA, VGA
  215. Example:     call    getcrt
  216.  
  217.  
  218.  
  219. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  220.  
  221. INSERT:      control INSERT key status
  222. Source:      insert.asm (cw$info.asm)
  223.  
  224. Call with:   AL = 0 to turn INSERT off in BIOS data area
  225.              AL = 1 to turn INSERT on in BIOS data area
  226. Returns:     nothing
  227. Uses:        nothing
  228. Example:
  229.  
  230. include codeseg.inc
  231.  
  232. extrn   insert:near
  233.  
  234. ; code
  235.  
  236.         mov     al,1         ; turn INSERT on in BIOS data area
  237.         call    insert
  238.  
  239.  
  240.  
  241. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  242.  
  243. ISANSI:      determines if ANSI or compatible is loaded and active
  244. Source:      isansi.asm
  245.  
  246. Call with:   no parameters
  247. Returns:     CF = 1 if no ANSI device driver loaded and active
  248.              CF = 0 if ANSI loaded and active
  249. Uses:        CF
  250. Example:
  251.  
  252. include codeseg.inc
  253.  
  254. extrn   isansi:near
  255.  
  256. ; code
  257.         .
  258.         .
  259.         .
  260.         call   isansi         ; let's see if ansi.sys is loaded
  261.         jc     no_ansi        ; jump if not
  262.  
  263.  
  264.  
  265. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  266.  
  267. ISATT:       determines if an ATT 6300-type display card is installed
  268.              this equipment is like a CGA except that it has an additional
  269.              640 x 400 2-color graphics mode (mode 40h)
  270. Source:      isatt.asm ($6845.asm, isevga.asm)
  271.  
  272. Call with:   no parameters
  273. Returns:     if CF = 1, ATT 6300 display not present
  274.              if CF = 0, ATT 6300 display is installed
  275. Uses:        flags
  276. Example:
  277.  
  278. public  cgamode
  279.  
  280. include codeseg.inc
  281.  
  282. extrn   isatt:near
  283.  
  284. ; code
  285. cgamode proc    near
  286.         mov     ax,06h             ; default: set CGA mode
  287.         call    isatt              ; see if mode 40h is available
  288.         jc      short set_mode     ;  nope
  289.         mov     ax,40h             ; use ATT 6300 mode 40h
  290. set_mode:
  291.         mov     v86r_ax,ax
  292.         mov     al,10h             ; use BIOS to set mode
  293.         int     30h
  294.         ret
  295.  
  296. cgamode endp
  297.  
  298. @curseg ends
  299.         end
  300.  
  301.  
  302. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  303.  
  304. ISEVGA:      determines if an EGA or VGA is installed
  305. Source:      isevga.asm
  306.  
  307. Call with:   no parameters
  308. Returns:     if CF = 1, no EGA or VGA
  309.              if CF = 0
  310.                DX = video memory in kbytes
  311.                AL = monitor type
  312.                 AL = -1 if monitor is CGA
  313.                 AL = 0 if monitor is monochrome
  314.                 AL = 1 if monitor is EGA or better
  315.  
  316.                AH = EGA/VGA flag
  317.                 AH = 1 if EGA
  318.                 AH = 3 if VGA
  319.  
  320. Uses:        AX, DX, CF
  321. Example:
  322.  
  323. include codeseg.inc
  324.  
  325. extrn   isevga:near
  326.  
  327. ; code
  328.         .
  329.         .
  330.         .
  331.         call   isevga
  332.         jc     no_evga
  333.  
  334.  
  335.  
  336. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  337.  
  338. ISHERC:      determines if a Hercules card or compatible is installed
  339.              and if so, determines if it is the active video system.
  340. Source:      isherc.asm ($herc.asm)
  341.  
  342. Call with:   no parameters
  343. Returns:     if CF = 1, no Hercules or compatible installed
  344.              if CF = 0, AX = Hercules model
  345.              128 = Hercules Graphics Card or compatible; active
  346.              144 = Hercules Graphics Card Plus; active
  347.              208 = Hercules InColor card; active
  348.              -128 = Hercules Graphics Card or compatible; not active
  349.              -144 = Hercules Graphics Card Plus; not active
  350.              -208 = Hercules InColor card; not active
  351. Uses:        AX, CF; all other flags and registers are saved
  352. Example:
  353.  
  354. include codeseg.inc
  355.  
  356. extrn   isherc:near
  357.  
  358. ; code
  359.         .
  360.         .
  361.         .
  362.         call  isherc
  363.         jc    no_herc
  364.  
  365.  
  366. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  367.  
  368. ISMONO:      detects a monochrome-compatible video card
  369.              this is handy in 2-monitor systems.
  370. Source:      $6845.asm
  371.  
  372. Call with:   no parameters
  373. Returns:     if CF = 1, no monochrome monitor
  374.              if CF = 0, monochrome monitor is installed
  375.                         including Hercules InColor
  376. Uses:        flags
  377. Supports:    MDA, EGA & VGA MONO, HGC, HGC+, InColor
  378. Example:
  379.  
  380. include codeseg.inc
  381.  
  382. extrn   ismono:near
  383.  
  384. ; code
  385.         .
  386.         .
  387.         .
  388.         call  ismono
  389.         jc    no_monochrome
  390.  
  391.  
  392.  
  393. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  394.  
  395. ISMOUSE:     determines if a mouse is installed
  396. Source:      ismouse.asm (asmflags.asm)
  397.  
  398. Call with:   no parameters
  399. Returns:     if CF = 0, AX = number of mouse buttons
  400.              if CF = 1, no mouse or mouse driver not installed
  401. Uses:        AX, flags
  402. Example:
  403.  
  404. include  codeseg.inc
  405.  
  406. extrn    ismouse:near
  407.  
  408. ; code
  409.         .
  410.         .
  411.         .
  412.         call    ismouse
  413.         jc      no_mouse
  414.  
  415.  
  416.  
  417. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  418.  
  419. ISSEVGA:     determines if a Super EGA or Super VGA is installed
  420. Source:      issevga.asm
  421.  
  422. Call with:   no parameters
  423. Returns:     if CF = 1, no Super EGA or Super VGA recognized by ASM32
  424.  
  425.              if CF = 0
  426.  
  427.               if AH = 1: (Super EGA)
  428.                AL = 1 if Paradise EGA 480
  429.                AL = 2 if Everex EGA
  430.  
  431.               if AH = 3: (Super VGA)
  432.                AL = 1 if Paradise VGA
  433.                AL = 3 if Tseng VGA chipset
  434.                AL = 4 if Oak VGA
  435.                AL = 5 if Western Digital VGA chipset
  436.  
  437.              See also IsEVGA and WhichVGA
  438. Uses:        AX, CF
  439. Example:
  440.  
  441. include codeseg.inc
  442.  
  443. extrn   issevga:near
  444.  
  445. ; code
  446.         .
  447.         .
  448.         .
  449.         call   issevga
  450.         jc     no_superevga
  451.  
  452.  
  453.  
  454. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  455.  
  456. MATHCHIP:    determines if x87 math coprocessor is installed
  457. Source:      mathchip.asm
  458.  
  459. Call with:   no parameters
  460. Returns:     AX = code for x87 model
  461.              0 = not installed
  462.              2 = 287                   ; earliest 386 computers used 287
  463.              3 = 387 (DX or SX)
  464.              4 = 487 (DX or SX)
  465.              If the coprocessor is present, it is initilaized by MathChip.
  466. Uses:        AX, all x87 registers
  467. Example:     call  mathchip
  468.  
  469.  
  470.  
  471.  
  472. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  473.  
  474. MOUSESAVE:   save mouse state
  475. Source:      moussave.asm
  476.  
  477. MOUSERESTORE:restore previously saved mouse state
  478. Source:      moussave.asm
  479.  
  480.              MouseSave and MouseRestore are handy when you have installed a
  481.              mouse event handler and you will be using the SYSTEM command,
  482.              where some other program may reset or otherwise change the
  483.              mouse event trapping.
  484.  
  485.              MouseSave allocates a buffer, saves the mouse state in the
  486.              buffer, resets the mouse driver and returns the buffer address.
  487.  
  488.              MouseRestore restores a specified mouse state and releases the
  489.              buffer.  Both MouseSave and MouseRestore assume that you already
  490.              know there is a mouse in the system.
  491.  
  492. Call with:   MouseSave: no paramerters
  493.              MouseRestore: AX = buffer address returned by MouseSave
  494. Returns:     if CF = 1, AH = DOS error code
  495.              if CF = 0, no error; MouseSave returns buffer address in AX
  496. Uses:        AX, flags
  497. Example:
  498.  
  499. include model.inc
  500. extrn   msave:near, mrestore:near
  501.  
  502. include dataseg.inc
  503. save_mouse dw 0
  504. @curseg    ends
  505.  
  506. include codeseg.inc
  507.  
  508.         .
  509.         .
  510.         .
  511.  
  512. ; save the mouse driver state
  513. ; I've already checked to see if there's a mouse
  514.         call    mousesave
  515.         jc      dos_error
  516.         mov     save_mouse,ax
  517.         .
  518.         .
  519. ; some other subroutine has messed with the mouse
  520.         mov     ax,save_mouse   ; buffer address from previous MSave
  521.         call    mouserestore
  522.         jc      dos_error
  523.  
  524.  
  525.  
  526. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  527.  
  528. PALETTE16:   change palette in EGA, VGA or SVGA 16-color mode
  529.              changing the palette changes the actual color associated
  530.              with a color attribute
  531. Source:      palet16.asm
  532.  
  533. Call with:   BH = color value (see Color16 in SYSTEM.DOC)
  534.              BL = color attribute to map color to (0-0Fh)
  535.              restore default palette with BX = 0FFFFh
  536. Returns:     nothing
  537. Uses:        nothing
  538. Supports:    EGA, VGA, SVGA 16-color modes, text or graphics
  539.              except EGA with CGA monitor
  540. Example:
  541.  
  542. include codeseg.inc
  543.  
  544. extrn   color16:near, palette16:near
  545.  
  546. ; data
  547. c16     db 3                  ; brightest red
  548.         db 1                  ; dim green
  549.         db 0                  ; no blue
  550.  
  551. ; code
  552.         .
  553.         .
  554.         .
  555.         lea   ebx,c16
  556.         call  color16
  557.         mov   bh,ah           ; color value in BH
  558.         mov   bl,15           ; color attribute 0Fh
  559.         call  palette16
  560.  
  561.  
  562.  
  563. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  564.  
  565. USE32K:      limit Hercules equipment to 32k memory (128k on InColor)
  566. USE64K:      allow full 64k on HGC and HGC+ (256k on InColor)
  567. Source:      $herc.asm
  568.  
  569. Requires Hercules or compatible
  570.  
  571. Call with:   no parameters
  572.              Use32k is equivalent to the Hercules "half" configuration
  573.              Use64k is equivalent to the Hercules "full" configuration
  574.              ASM32's default is "half".  Use this configuration if you
  575.              have a 2-monitor system, unless you are using the Hercules
  576.              CGA card. 
  577. Returns:     nothing
  578. Uses:        nothing
  579. Example:     ; in this example I'm determining if a Hercules is installed
  580.              ; and setting the configuration to "full"
  581.  
  582.  
  583. extrn   IsHerc:near
  584. extrn   Use64k:near
  585.  
  586. include codeseg.inc
  587.  
  588.         .
  589.         .
  590.         .
  591.         call  IsHerc
  592.         jc    no_herc
  593.         or    ax,ax
  594.  
  595. ; use_only_half if HGC is not default monitor
  596.         js    short use_only_half
  597.         call  use64k          ; else use all Hercules memory
  598. use_only_half:
  599.  
  600.  
  601. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  602.  
  603. WHICHVGA:    determine if VGAKIT-compatible SuperVGA is installed
  604.              See SVGA16 and SVGA256 in MODE.DOC.
  605. Source:      whichvga.asm ($banks.asm)
  606.  
  607. Call with:   no parameters
  608. Returns:     if VGAKIT-compatible Super VGA is installed, AX <> 0.
  609.              if no VGAKIT equipment is installed, AX = 0.
  610. Uses:        AX
  611. Example:     see SVGA16 in MODE.DOC
  612.  
  613.